﻿@{
    Layout = "~/Views/Shared/_Form.cshtml";
}
@section scripts{
    <script type="text/javascript">
        var oTable;
        var ProInfo;
        $(function () {
            $("#system").removeClass("right-menu").addClass("right-menu-active");
            $("#Department").addClass("active");
            oTable = $('#pTable').dataTable({
                 "oLanguage": {
                     "sUrl": "@Url.Content("~/Content/js/vendors/DataTables/dataTables.chinese.txt")"
                 },
                "bServerSide": true,
                "sAjaxSource": path + "Department/GetDepartmentList",      //mvc后台ajax调用接口
                'bPaginate': true,                      //是否分页。
                "bProcessing": true,                    //当datatable获取数据时候是否显示正在处理提示信息。
                'bFilter': false,                       //是否使用内置的过滤功能。
                "bSort": false,
                "iDisplayLength": 5,                   //每页显示的行数
                "bLengthChange": false,                 //允许用户从一个选择菜单中格式化页面大小(改变页面显示的数据数量)
                'sPaginationType': 'full_numbers',      //分页样式
                "fnServerParams": function (aoData) {
                    aoData.push({ "name": "NAME", "value": "" });
                },
                "aoColumns": [
                    { "mData": "Id", "sTitle": "主键", "bVisible": false, "bSearchable": false, "bSortable": false },
                    { "mData": "BMBM", "sTitle": "部门编码", "sWidth": "15%" },
                    { "mData": "BMMC", "sTitle": "部门名称", "sWidth": "20%" },
                    { "mData": "MANAGER", "sTitle": "管理人", "sWidth": "10%" },
                    { "mData": "PHONE", "sTitle": "电话", "sWidth": "20%" },
                    { "mData": "EXTENDCODE", "sTitle": "人数", "sWidth": "10%" },
                    {
                        "mData": "ISVALID", "sTitle": "是否有效", "sWidth": "15%",
                        "mRender": function (data, type,full) {
                            var html = "";
                            if (full.ISVALID == "1") {
                                html = "<span class='label label-success'style='font-size: 12px'>有效</span>";
                            }
                            else {
                                html = "<span class='label label-danger'style='font-size: 12px'>无效</span>";
                            }
                            return html;
                        }}
                ]
            });
        });
        $("#pTable").on("click", "tr", function () {//给tr或者td添加click事件
            var table = $('#pTable').DataTable();
            var data = table.row(this).data();
            parent.$('#BMMC').val(data.BMMC);
            parent.$('#DEPTID').val(data.Id);
            parent.ProInfo.close(function (id) {
                console.log(id);
            });
        });
        //function AlertInfo(content, typeInfo) {
        //    noty({ text: content, type: typeInfo, layout: "topCenter", timeout: 2000 });
        //    if (typeInfo == 'success') {
        //        ProInfo.close();
        //        oTable.fnDraw();
        //    }
        //};
    </script>
}


<div class="row" id="powerwidgets">
    <div class="col-md-12 bootstrap-grid sortable-grid ui-sortable">
        <div class="powerwidget powerwidget-sortable" id="datatable-basic-init" data-widget-editbutton="false" role="widget" style="">
            <div class="inner-spacer">
                <div id="table-1_wrapper" class="dataTables_wrapper form-inline" role="grid">
                    <table class="table table-striped table-hover dataTable" id="pTable" aria-describedby="table-1_info"></table>
                </div>
            </div>
        </div>
    </div>
</div>
